<?php 
$companyid=$session->read("companyid");
$user=$session->read('User');
$isflag=$action->checkPermissions($user,$companyid);
?>
<?php echo $javascript->link('jquery.timelinr-0.9.4.js');?>
<script type="text/javascript">
	$(function(){
		$().timelinr({
			orientation: 'horizontal',
			containerDiv: '#timeline',
			datesDiv: '#dates',
			datesSelectedClass: 'selected',
			datesSpeed: 500,
			issuesDiv : '#issues',
			issuesSelectedClass: 'selected',
			issuesSpeed: 200,
			issuesTransparency: 0.2,
			issuesTransparencySpeed: 500,
			prevButton: '#prev',
			nextButton: '#next',
			arrowKeys: 'false',
			startAt: 1,
			autoPlay: 'false',
			autoPlayDirection: 'forward',
			autoPlayPause: 2000
	 	});
	});
</script>
<div class="right_side_operate_area">
	<div class="right_side_title left">
		<h2>
			<?php 
			$companyname=$session->read("companyname");
			echo $html->link($companyname,"/companys/showinfosummary/".$companyid);
			?>
		</h2>
		<div class="clear"></div>
	</div>
   <?php 
		//if($isflag){
    		echo '<div class="right item_add_btn">';
			echo $html->link(__('添加',true), 'editdepcost');
			echo '</div>';
		//}else{
			//echo '<div class="right enableaction">';
		//	echo "<a>添加</a>";
			//echo '</div>';
		//}
	?>
    <div class="clear"></div>
    <div class="right_sidt_head_screen">
    	<div class="left">
		    <div class="right_side_head_line">
				<ul>
					<li style="width:300px">
						<div class="left screen_condition">总研发费用（元）：</div>
						<div class="left screen_counts" id="sumprice">0</div>
						<div class="clear"></div>
					</li>
				</ul>
			</div>
		</div>
		<div class="right display_by_year_btn"><?php echo $html->link('返回',"/companys/depcosts/",null,null); ?></div>
		<div class="clear"></div>
	</div>
</div>
<div class="right_side_scollbar">
	<div class="detail_info_panel">
        <div class="time_line_panel" id='time_panel'>
        	<div class="time_line_area" id="timeline">
            	<ul id="dates">
            	 	<?php foreach($objyears as $stryear){
            	 		$c_time=$stryear[0]['c_time'];
            	 	?>
            	 	<li><a href="#<?php echo $c_time ?>"><?php echo $c_time ?></a></li>
            	 	<?php }?>
                </ul>
                <ul id="issues">
                	<?php 
                	$sumprices=0;
                	foreach($objyears as $key=>$stryear){
                		$c_time=$stryear[0]['c_time'];
                	?>
                    <li id="<?php echo $c_time ?>">
                        <div class="issue_details">
                        	<div class="right_sidt_screen_by_year">
                        		<div class="right_side_head_line">
                        			<div class="left per_screen_by_time" style="width:auto">
                        				<div class="left screen_condition">
                        					本年度总研发费用（元）：
                        				</div>
                        				<div class="left screen_counts" id="sumprice<?php echo $c_time?>">0</div>
                        				<div class="clear"></div>
                        			</div>
                        			<div class="clear"></div>
                        		</div>
                        	  	<div class="items_list" id='panel'>
						        	<table>
					            	<tr>
					                	<th><?php echo '时间'; ?></th>
					                    <th><?php echo '研发费用（元）' ;?></th>
					                    <th>研究与实验（元）</th>
					                    <th>新产品费用（元）</th>
					                    <th>政府拨款（元）</th>
					                    <th>企业自筹费用（元）</th>
					                    <th><?php __("Action")?></th>
					                </tr>
					                <?php 
					                $sumprice=0;
					                $costs=$stryear['costs'];
									foreach($costs as $cost){
										$id=$cost["DevelopmentCost"]["id"];
										echo "<tr class='per_list'>";
										echo "<td>".$html->link(date("Y-m-d",strtotime($cost["DevelopmentCost"]["c_time"])),"/companys/showdepcost/".$id)."</td>";
										$dcost=$cost['DevelopmentCost']['cost'];
										$sumprice+=$dcost;
										echo "<td>".$dcost."</td>";
										echo "<td>".$cost['DevelopmentCost']['research_exp']."</td>";
										echo "<td>".$cost['DevelopmentCost']['new_product']."</td>";
										echo "<td>".$cost['DevelopmentCost']['govern_funding']."</td>";
										echo "<td>".$cost['DevelopmentCost']['raised_enterprise']."</td>";
										echo "<td>";
										//if($isflag){
											echo $html->link(__("Edit",true),"/companys/editdepcost/".$id,null,null);
											echo $html->link(__("Delete",true),"/companys/deldepcost/".$id,array("onclick"=>"return doaction(this)"));
										//}else{
											//echo "<span class='enableaction'>编辑</span>";
											//echo "<span class='enableaction'>删除</span>";
										//}
										echo "</td>";
										echo "</tr>";
									}
									$sumprices+=$sumprice;
									?>
						            </table>
						            <?php if($sumprice){?>
						            	<script>$("#sumprice<?php echo $c_time?>").html("<?php echo $sumprice?>");</script>
						            <?php }?>
						      	</div>
							</div>
                        </div>
                    </li>
                    <?php }?>
                     <?php if($sumprices){?>
		            	<script>$("#sumprice").html("<?php echo $sumprices?>");</script>
		            <?php }?>
                </ul>
                <div id="issue_panel_arrow"></div>
                <div id="grad_left"></div>
				<div id="grad_right"></div>
                <a href="#" id="next">+</a>
                <a href="#" id="prev">-</a>
            </div>
        </div>
    </div>
</div>
<?php echo $this->element('actionconfirm',array("title"=>"删除提示","message"=>"你确定要删除吗？")) ?>